package com.example.demo.service;

import com.example.demo.entity.StudentInfo;
import com.example.demo.mapper.StudentInfoMapper;
import com.example.demo.vo.StudentClassInfo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentInfoServiceImpl implements StudentInfoService {
    @Autowired
    private StudentInfoMapper studentInfoMapper;

    @Override
    public List<StudentInfo> getAllStudentInfo(String name) {
        return studentInfoMapper.getAllStudentInfo(name);
    }

    @Override
    public List<StudentClassInfo> getAllStuAndClassByName(String stuName) {
        List<StudentClassInfo> allStuAndClassByName = studentInfoMapper.getAllStuAndClassByName(stuName);
        return allStuAndClassByName;
    }

    @Override
    public Integer deleteByID(Integer stuid) {
        Integer i = studentInfoMapper.deleteByID(stuid);
        return i;

    }

    @Override
    public Integer insertStudentInfo(StudentInfo studentInfo) {
        return studentInfoMapper.insertStudentInfo(studentInfo);
    }

    @Override
    public Integer updateStudentInfo(StudentInfo studentInfo) {
        return studentInfoMapper.updateStudentInfo(studentInfo);
    }

    @Override
    public PageInfo<StudentClassInfo> getPageStudentInfoClassInfo(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<StudentClassInfo> allStuAndClassByName = studentInfoMapper.getAllStuAndClassByName("");
        PageInfo<StudentClassInfo> pageInfo = new PageInfo<>(allStuAndClassByName);
        return pageInfo;
    }

    @Override
    public List<StudentClassInfo> getAllClassByclsAndName(String stuName, Integer clsid) {
        return studentInfoMapper.getAllClassByclsAndName(stuName, clsid);
    }

    @Override
    public Integer deleteStuById(Integer id) {
        return 0;
    }

}
